home *** CD-ROM | disk | FTP | other *** search
/ Aminet 52 / Aminet 52 (2002)(GTI - Schatztruhe)[!][Dec 2002].iso / Aminet / dev / lang / amigatalk.lha / system / ClipBoard.st < prev    next >
Text File  |  2001-02-04  |  4KB  |  138 lines

  1. " ---------------------------------------------------------------------"
  2. " ClipBoard Class is derived from abstract Device Class.               "
  3. ""
  4. "  WARNING:  You should know what you're doing to the Amiga OS before  "
  5. "            messing with this Class, or any other System Class!       "
  6. " ---------------------------------------------------------------------"
  7.  
  8. Class ClipBoard :Device ! unitNumber !
  9. [
  10.    new: unitNum
  11.       self setClipUnit: unitNum.
  12.       ^ self
  13. |
  14.    new
  15.       ^ self new: 0
  16. |
  17.    openHookedClipboard: clipNumber withHook: aHook ! check !
  18.       "Read the help file about this method."
  19.       check <- <primitive 221 5 clipNumber aHook>.
  20.  
  21.       (check == nil)
  22.          ifTrue: [ 'Clip #',clipNumber,' did NOT open!' print.
  23.                    ^ nil
  24.                  ].
  25.          
  26.       ^ self setClipUnit: clipNumber
  27. |      
  28.    closeHookedClipboard
  29.       "Read the help file about this method."
  30.       <primitive 221 6 unitNumber>
  31. |
  32.    setClipUnit: unitNum
  33.       ^ unitNumber <- unitNum
  34. |
  35.    writeFTXTClipToFTXTFile: fileName ! check !
  36.       check <- <primitive 221 2 unitNumber fileName>.
  37.       
  38.       (check ~= 0)
  39.          ifTrue: [ 'Clip did NOT make it to file ',fileName print.
  40.                    <primitive 221 9 check> print
  41.                  ]
  42. |
  43.    writeFTXTClipToASCIIFile: filename ! check !
  44.       check <- <primitive 221 4 filename unitNumber>.
  45.  
  46.       (check ~= 0)
  47.          ifTrue: [ 'Clip did NOT make it to file ',filename print.
  48.                    <primitive 221 9 check> print.
  49.                    ^ nil
  50.                  ]
  51. |
  52.    postFTXTToClip: ftxtString ! check !
  53.       "Experimental, DO NOT USE."
  54.       check <- <primitive 221 13 unitNumber ftxtString>.
  55.       
  56.       (check ~= 0)
  57.          ifTrue: [ 'string did NOT make it to the clipboard!' print.
  58.                    <primitive 221 9 check> print
  59.                  ]
  60. |
  61.    postAsciiFileToClip: fileName ! check !
  62.       check <- <primitive 221 0 unitNumber fileName>.
  63.       
  64.       (check ~= 0)
  65.          ifTrue: [ fileName,' did NOT make it to the clipboard!' print.
  66.                    <primitive 221 9 check> print
  67.                  ]
  68. |
  69.    update            "Send CMD_UPDATE to the device"
  70.       (<primitive 221 12 unitNumber> ~= true)
  71.          ifTrue: [ 'Clipboard update method failed!' print]
  72. |
  73.    postFTXTFileToClip: fileName ! check !
  74.       check <- <primitive 221 7 unitNumber fileName>.
  75.       
  76.       (check ~= 0)
  77.          ifTrue: [ fileName,' did NOT make it to the clipboard!' print.
  78.                    <primitive 221 9 check> print
  79.                  ]
  80. |
  81.    postILBMFileToClip: fileName ! check !
  82.       check <- <primitive 221 8 unitNumber fileName>.
  83.       
  84.       (check ~= 0)
  85.          ifTrue: [ fileName,' did NOT make it to the clipboard!' print.
  86.                    <primitive 221 9 check> print
  87.                  ]
  88. |
  89.    writeILBMClipToFile: fileName ! check !
  90.       check <- <primitive 221 14 unitNumber fileName>.
  91.       
  92.       (check ~= 0)
  93.          ifTrue: [ 'Clip did NOT make it to file ', fileName print.
  94.                    <primitive 221 9 check> print
  95.                  ]
  96. |
  97.    postAsciiStringToClip: clipString
  98.       <primitive 221 1 clipString unitNumber>
  99.    clipTypeIs ! clipType !
  100.       clipType <- <primitive 221 3 unitNumber>.
  101.       
  102.       (clipType == nil)
  103.          ifTrue: [ ^ #CLIP_ERROR ].
  104.       
  105.       (clipType == true)   
  106.          ifTrue:  [ ^ #FTXT ].
  107.       
  108.       ^ #ILBM
  109.  
  110. "----------------------------------------------------------------------"
  111. " IFFClipBoard Class is derived from abstract Device Class.            "
  112. "  This class only reads & writes FTXT to clipboard.                   "
  113. ""
  114. "  WARNING:  You should know what you're doing to the Amiga OS before  "
  115. "            messing with this Class, or any other System Class!       "
  116. "----------------------------------------------------------------------"
  117.  
  118. Class IFFClipBoard :Device
  119. [
  120.    postToClipUnit: unit fromFTXTString: ftxtString ! check !
  121.       check <- <primitive 221 10 unit ftxtString>.
  122.  
  123.       (check ~= 0)
  124.          ifTrue: [ 'String did NOT make it to Clipboard!' print.
  125.                    <primitive 221 9 check> print
  126.                  ]
  127. |
  128.    writeFTXTClip: unit toFTXTString: ftxtString size: numBytes ! check !
  129.       check <- <primitive 221 11 unit numBytes ftxtString>.
  130.       
  131.       (check ~= 0)
  132.          ifTrue: [ 'Clip did NOT make it to string!' print.
  133.                    <primitive 221 9 check> print
  134.                  ]
  135. ]
  136.